package main

import (
	"fmt"
	"math/rand"
	"time"
)

//数组练习
func main() {
	var myChar [26]byte
	for i := 0; i < len(myChar); i++ {
		myChar[i] = byte('A' + i)
	}
	fmt.Printf("myChar的值 %c \n", myChar)

	maxVal()

	printVal()
}

//获取数组的最大值
func maxVal() {
	arr := [5]int{3424, 42, 54, 221, 76}
	maxValue := arr[0]
	valueIndex := 0

	for i := 1; i < len(arr); i++ {
		if maxValue < arr[i] {
			maxValue = arr[i]
			valueIndex = i
		}
	}

	fmt.Printf("最大值 %v, 下标位 %v \n", maxValue, valueIndex)
}

func printVal() {
	var arr [5]int
	rand.Seed(time.Now().UnixNano())
	for i := 0; i < len(arr); i++ {

		arr[i] = rand.Intn(100)

	}

	for i := len(arr) - 1; i >= 0; i-- {
		fmt.Println("数组相反打印", arr[i])
	}

}
